// $ANTLR 3.3 Nov 30, 2010 12:45:30 C:\\projects\\Expressions\\antlr\\Expression.g 2011-04-28 19:47:48

// The variable 'variable' is assigned but its value is never used.
#pragma warning disable 219
// Unreachable code detected.
#pragma warning disable 162


using System;
using System.Collections.Generic;
using Antlr.Runtime;
using Antlr.Runtime.Tree;

namespace SimpleSpreadsheet.Core.Parser
{
    [System.CodeDom.Compiler.GeneratedCode("ANTLR", "3.3 Nov 30, 2010 12:45:30")]
    [System.CLSCompliant(false)]
    public partial class ExpressionParser : ExtendedParserBase
    {
        internal static readonly string[] tokenNames = new string[] {
                                                                        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "PARAM", "REFERENCE", "RANGEREFERENCE", "NEGATE", "STRING", "OR", "AND", "EQUALS", "NOTEQUALS", "LT", "LTEQ", "GT", "GTEQ", "PLUS", "MINUS", "MULT", "DIV", "MOD", "POW", "NOT", "INTEGER", "FLOAT", "REF", "REFRANGE", "PAR", "EscapeSequence", "IDENT", "UnicodeEscape", "HexDigit", "WS", "'('", "')'", "','"
                                                                    };
        public const int EOF = -1;
        public const int T__34 = 34;
        public const int T__35 = 35;
        public const int T__36 = 36;
        public const int PARAM = 4;
        public const int REFERENCE = 5;
        public const int RANGEREFERENCE = 6;
        public const int NEGATE = 7;
        public const int STRING = 8;
        public const int OR = 9;
        public const int AND = 10;
        public const int EQUALS = 11;
        public const int NOTEQUALS = 12;
        public const int LT = 13;
        public const int LTEQ = 14;
        public const int GT = 15;
        public const int GTEQ = 16;
        public const int PLUS = 17;
        public const int MINUS = 18;
        public const int MULT = 19;
        public const int DIV = 20;
        public const int MOD = 21;
        public const int POW = 22;
        public const int NOT = 23;
        public const int INTEGER = 24;
        public const int FLOAT = 25;
        public const int REF = 26;
        public const int REFRANGE = 27;
        public const int PAR = 28;
        public const int EscapeSequence = 29;
        public const int IDENT = 30;
        public const int UnicodeEscape = 31;
        public const int HexDigit = 32;
        public const int WS = 33;

        // delegates
        // delegators

#if ANTLR_DEBUG
		private static readonly bool[] decisionCanBacktrack =
			new bool[]
			{
				false, // invalid decision
				false, false, false, false, false, false, false, false, false, false, 
				false, false
			};
#else
        private static readonly bool[] decisionCanBacktrack = new bool[0];
#endif
        public ExpressionParser(ITokenStream input)
            : this(input, new RecognizerSharedState())
        {
        }
        public ExpressionParser(ITokenStream input, RecognizerSharedState state)
            : base(input, state)
        {
            ITreeAdaptor treeAdaptor = null;
            CreateTreeAdaptor(ref treeAdaptor);
            TreeAdaptor = treeAdaptor ?? new CommonTreeAdaptor();

            OnCreated();
        }

        // Implement this function in your helper file to use a custom tree adaptor
        partial void CreateTreeAdaptor(ref ITreeAdaptor adaptor);

        private ITreeAdaptor adaptor;

        public ITreeAdaptor TreeAdaptor
        {
            get
            {
                return adaptor;
            }
            set
            {
                this.adaptor = value;
            }
        }

        public override string[] TokenNames { get { return ExpressionParser.tokenNames; } }
        public override string GrammarFileName { get { return "C:\\projects\\Expressions\\antlr\\Expression.g"; } }


        List<Exception> exceptions = new List<Exception>();

        public override void ReportError(RecognitionException e)
        {
            exceptions.Add(e);
        }

        public bool HasError
        {
            get { return exceptions.Count > 0; }
        }

        public string ErrorMessage
        {
            get { return this.GetErrorMessage(exceptions[0] as RecognitionException, this.TokenNames); }
        }

        public string ErrorPosition
        {
            get { return this.GetErrorHeader(exceptions[0] as RecognitionException); }
        }


        partial void OnCreated();
        partial void EnterRule(string ruleName, int ruleIndex);
        partial void LeaveRule(string ruleName, int ruleIndex);

        #region Rules
        //public class expression_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<CommonTree>
        //{
        //    private CommonTree _tree;
        //    public CommonTree Tree { get { return _tree; } set { _tree = value; } }
        //    object IAstRuleReturnScope.Tree { get { return Tree; } }
        //}

        partial void Enter_expression();
        partial void Leave_expression();

        // $ANTLR start "expression"
        // C:\\projects\\Expressions\\antlr\\Expression.g:48:1: expression : logicalExpression EOF ;
        [GrammarRule("expression")]
        public override expression_return Expression()
        {
            Enter_expression();
            EnterRule("expression", 1);
            TraceIn("expression", 1);
            expression_return retval = new expression_return();
            retval.Start = (IToken)input.LT(1);

            CommonTree root_0 = null;

            IToken EOF2 = null;
            ExpressionParser.logicalExpression_return logicalExpression1 = default(ExpressionParser.logicalExpression_return);

            CommonTree EOF2_tree = null;

            try
            {
                DebugEnterRule(GrammarFileName, "expression");
                DebugLocation(48, 1);
                try
                {
                    // C:\\projects\\Expressions\\antlr\\Expression.g:49:2: ( logicalExpression EOF )
                    DebugEnterAlt(1);
                    // C:\\projects\\Expressions\\antlr\\Expression.g:49:5: logicalExpression EOF
                    {
                        root_0 = (CommonTree)adaptor.Nil();

                        DebugLocation(49, 5);
                        PushFollow(Follow._logicalExpression_in_expression72);
                        logicalExpression1 = logicalExpression();
                        PopFollow();

                        adaptor.AddChild(root_0, logicalExpression1.Tree);
                        DebugLocation(49, 26);
                        EOF2 = (IToken)Match(input, EOF, Follow._EOF_in_expression74);

                    }

                    retval.Stop = (IToken)input.LT(-1);

                    retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                    adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

                }
                catch (RecognitionException re)
                {
                    ReportError(re);
                    Recover(input, re);
                    retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

                }
                finally
                {
                    TraceOut("expression", 1);
                    LeaveRule("expression", 1);
                    Leave_expression();
                }
                DebugLocation(50, 1);
            }
            finally { DebugExitRule(GrammarFileName, "expression"); }
            return retval;

        }
        // $ANTLR end "expression"

        public class logicalExpression_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<CommonTree>
        {
            private CommonTree _tree;
            public CommonTree Tree { get { return _tree; } set { _tree = value; } }
            object IAstRuleReturnScope.Tree { get { return Tree; } }
        }

        partial void Enter_logicalExpression();
        partial void Leave_logicalExpression();

        // $ANTLR start "logicalExpression"
        // C:\\projects\\Expressions\\antlr\\Expression.g:52:1: logicalExpression : booleanAndExpression ( OR booleanAndExpression )* ;
        [GrammarRule("logicalExpression")]
        private ExpressionParser.logicalExpression_return logicalExpression()
        {
            Enter_logicalExpression();
            EnterRule("logicalExpression", 2);
            TraceIn("logicalExpression", 2);
            ExpressionParser.logicalExpression_return retval = new ExpressionParser.logicalExpression_return();
            retval.Start = (IToken)input.LT(1);

            CommonTree root_0 = null;

            IToken OR4 = null;
            ExpressionParser.booleanAndExpression_return booleanAndExpression3 = default(ExpressionParser.booleanAndExpression_return);
            ExpressionParser.booleanAndExpression_return booleanAndExpression5 = default(ExpressionParser.booleanAndExpression_return);

            CommonTree OR4_tree = null;

            try
            {
                DebugEnterRule(GrammarFileName, "logicalExpression");
                DebugLocation(52, 1);
                try
                {
                    // C:\\projects\\Expressions\\antlr\\Expression.g:53:2: ( booleanAndExpression ( OR booleanAndExpression )* )
                    DebugEnterAlt(1);
                    // C:\\projects\\Expressions\\antlr\\Expression.g:53:4: booleanAndExpression ( OR booleanAndExpression )*
                    {
                        root_0 = (CommonTree)adaptor.Nil();

                        DebugLocation(53, 4);
                        PushFollow(Follow._booleanAndExpression_in_logicalExpression88);
                        booleanAndExpression3 = booleanAndExpression();
                        PopFollow();

                        adaptor.AddChild(root_0, booleanAndExpression3.Tree);
                        DebugLocation(53, 25);
                        // C:\\projects\\Expressions\\antlr\\Expression.g:53:25: ( OR booleanAndExpression )*
                        try
                        {
                            DebugEnterSubRule(1);
                            while (true)
                            {
                                int alt1 = 2;
                                try
                                {
                                    DebugEnterDecision(1, decisionCanBacktrack[1]);
                                    int LA1_0 = input.LA(1);

                                    if ((LA1_0 == OR))
                                    {
                                        alt1 = 1;
                                    }


                                }
                                finally { DebugExitDecision(1); }
                                switch (alt1)
                                {
                                    case 1:
                                        DebugEnterAlt(1);
                                        // C:\\projects\\Expressions\\antlr\\Expression.g:53:26: OR booleanAndExpression
                                        {
                                            DebugLocation(53, 28);
                                            OR4 = (IToken)Match(input, OR, Follow._OR_in_logicalExpression91);
                                            OR4_tree = (CommonTree)adaptor.Create(OR4);
                                            root_0 = (CommonTree)adaptor.BecomeRoot(OR4_tree, root_0);

                                            DebugLocation(53, 30);
                                            PushFollow(Follow._booleanAndExpression_in_logicalExpression94);
                                            booleanAndExpression5 = booleanAndExpression();
                                            PopFollow();

                                            adaptor.AddChild(root_0, booleanAndExpression5.Tree);

                                        }
                                        break;

                                    default:
                                        goto loop1;
                                }
                            }

                            loop1:
                            ;

                        }
                        finally { DebugExitSubRule(1); }


                    }

                    retval.Stop = (IToken)input.LT(-1);

                    retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                    adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

                }
                catch (RecognitionException re)
                {
                    ReportError(re);
                    Recover(input, re);
                    retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

                }
                finally
                {
                    TraceOut("logicalExpression", 2);
                    LeaveRule("logicalExpression", 2);
                    Leave_logicalExpression();
                }
                DebugLocation(54, 1);
            }
            finally { DebugExitRule(GrammarFileName, "logicalExpression"); }
            return retval;

        }
        // $ANTLR end "logicalExpression"

        public class booleanAndExpression_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<CommonTree>
        {
            private CommonTree _tree;
            public CommonTree Tree { get { return _tree; } set { _tree = value; } }
            object IAstRuleReturnScope.Tree { get { return Tree; } }
        }

        partial void Enter_booleanAndExpression();
        partial void Leave_booleanAndExpression();

        // $ANTLR start "booleanAndExpression"
        // C:\\projects\\Expressions\\antlr\\Expression.g:58:1: booleanAndExpression : equalityExpression ( AND equalityExpression )* ;
        [GrammarRule("booleanAndExpression")]
        private ExpressionParser.booleanAndExpression_return booleanAndExpression()
        {
            Enter_booleanAndExpression();
            EnterRule("booleanAndExpression", 3);
            TraceIn("booleanAndExpression", 3);
            ExpressionParser.booleanAndExpression_return retval = new ExpressionParser.booleanAndExpression_return();
            retval.Start = (IToken)input.LT(1);

            CommonTree root_0 = null;

            IToken AND7 = null;
            ExpressionParser.equalityExpression_return equalityExpression6 = default(ExpressionParser.equalityExpression_return);
            ExpressionParser.equalityExpression_return equalityExpression8 = default(ExpressionParser.equalityExpression_return);

            CommonTree AND7_tree = null;

            try
            {
                DebugEnterRule(GrammarFileName, "booleanAndExpression");
                DebugLocation(58, 1);
                try
                {
                    // C:\\projects\\Expressions\\antlr\\Expression.g:59:2: ( equalityExpression ( AND equalityExpression )* )
                    DebugEnterAlt(1);
                    // C:\\projects\\Expressions\\antlr\\Expression.g:59:4: equalityExpression ( AND equalityExpression )*
                    {
                        root_0 = (CommonTree)adaptor.Nil();

                        DebugLocation(59, 4);
                        PushFollow(Follow._equalityExpression_in_booleanAndExpression124);
                        equalityExpression6 = equalityExpression();
                        PopFollow();

                        adaptor.AddChild(root_0, equalityExpression6.Tree);
                        DebugLocation(59, 23);
                        // C:\\projects\\Expressions\\antlr\\Expression.g:59:23: ( AND equalityExpression )*
                        try
                        {
                            DebugEnterSubRule(2);
                            while (true)
                            {
                                int alt2 = 2;
                                try
                                {
                                    DebugEnterDecision(2, decisionCanBacktrack[2]);
                                    int LA2_0 = input.LA(1);

                                    if ((LA2_0 == AND))
                                    {
                                        alt2 = 1;
                                    }


                                }
                                finally { DebugExitDecision(2); }
                                switch (alt2)
                                {
                                    case 1:
                                        DebugEnterAlt(1);
                                        // C:\\projects\\Expressions\\antlr\\Expression.g:59:24: AND equalityExpression
                                        {
                                            DebugLocation(59, 27);
                                            AND7 = (IToken)Match(input, AND, Follow._AND_in_booleanAndExpression127);
                                            AND7_tree = (CommonTree)adaptor.Create(AND7);
                                            root_0 = (CommonTree)adaptor.BecomeRoot(AND7_tree, root_0);

                                            DebugLocation(59, 29);
                                            PushFollow(Follow._equalityExpression_in_booleanAndExpression130);
                                            equalityExpression8 = equalityExpression();
                                            PopFollow();

                                            adaptor.AddChild(root_0, equalityExpression8.Tree);

                                        }
                                        break;

                                    default:
                                        goto loop2;
                                }
                            }

                            loop2:
                            ;

                        }
                        finally { DebugExitSubRule(2); }


                    }

                    retval.Stop = (IToken)input.LT(-1);

                    retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                    adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

                }
                catch (RecognitionException re)
                {
                    ReportError(re);
                    Recover(input, re);
                    retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

                }
                finally
                {
                    TraceOut("booleanAndExpression", 3);
                    LeaveRule("booleanAndExpression", 3);
                    Leave_booleanAndExpression();
                }
                DebugLocation(60, 1);
            }
            finally { DebugExitRule(GrammarFileName, "booleanAndExpression"); }
            return retval;

        }
        // $ANTLR end "booleanAndExpression"

        public class equalityExpression_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<CommonTree>
        {
            private CommonTree _tree;
            public CommonTree Tree { get { return _tree; } set { _tree = value; } }
            object IAstRuleReturnScope.Tree { get { return Tree; } }
        }

        partial void Enter_equalityExpression();
        partial void Leave_equalityExpression();

        // $ANTLR start "equalityExpression"
        // C:\\projects\\Expressions\\antlr\\Expression.g:64:1: equalityExpression : relationalExpression ( ( EQUALS | NOTEQUALS ) relationalExpression )* ;
        [GrammarRule("equalityExpression")]
        private ExpressionParser.equalityExpression_return equalityExpression()
        {
            Enter_equalityExpression();
            EnterRule("equalityExpression", 4);
            TraceIn("equalityExpression", 4);
            ExpressionParser.equalityExpression_return retval = new ExpressionParser.equalityExpression_return();
            retval.Start = (IToken)input.LT(1);

            CommonTree root_0 = null;

            IToken set10 = null;
            ExpressionParser.relationalExpression_return relationalExpression9 = default(ExpressionParser.relationalExpression_return);
            ExpressionParser.relationalExpression_return relationalExpression11 = default(ExpressionParser.relationalExpression_return);

            CommonTree set10_tree = null;

            try
            {
                DebugEnterRule(GrammarFileName, "equalityExpression");
                DebugLocation(64, 1);
                try
                {
                    // C:\\projects\\Expressions\\antlr\\Expression.g:65:2: ( relationalExpression ( ( EQUALS | NOTEQUALS ) relationalExpression )* )
                    DebugEnterAlt(1);
                    // C:\\projects\\Expressions\\antlr\\Expression.g:65:4: relationalExpression ( ( EQUALS | NOTEQUALS ) relationalExpression )*
                    {
                        root_0 = (CommonTree)adaptor.Nil();

                        DebugLocation(65, 4);
                        PushFollow(Follow._relationalExpression_in_equalityExpression158);
                        relationalExpression9 = relationalExpression();
                        PopFollow();

                        adaptor.AddChild(root_0, relationalExpression9.Tree);
                        DebugLocation(65, 25);
                        // C:\\projects\\Expressions\\antlr\\Expression.g:65:25: ( ( EQUALS | NOTEQUALS ) relationalExpression )*
                        try
                        {
                            DebugEnterSubRule(3);
                            while (true)
                            {
                                int alt3 = 2;
                                try
                                {
                                    DebugEnterDecision(3, decisionCanBacktrack[3]);
                                    int LA3_0 = input.LA(1);

                                    if (((LA3_0 >= EQUALS && LA3_0 <= NOTEQUALS)))
                                    {
                                        alt3 = 1;
                                    }


                                }
                                finally { DebugExitDecision(3); }
                                switch (alt3)
                                {
                                    case 1:
                                        DebugEnterAlt(1);
                                        // C:\\projects\\Expressions\\antlr\\Expression.g:65:26: ( EQUALS | NOTEQUALS ) relationalExpression
                                        {
                                            DebugLocation(65, 26);
                                            set10 = (IToken)input.LT(1);
                                            set10 = (IToken)input.LT(1);
                                            if ((input.LA(1) >= EQUALS && input.LA(1) <= NOTEQUALS))
                                            {
                                                input.Consume();
                                                root_0 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(set10), root_0);
                                                state.errorRecovery = false;
                                            }
                                            else
                                            {
                                                MismatchedSetException mse = new MismatchedSetException(null, input);
                                                DebugRecognitionException(mse);
                                                throw mse;
                                            }

                                            DebugLocation(65, 46);
                                            PushFollow(Follow._relationalExpression_in_equalityExpression168);
                                            relationalExpression11 = relationalExpression();
                                            PopFollow();

                                            adaptor.AddChild(root_0, relationalExpression11.Tree);

                                        }
                                        break;

                                    default:
                                        goto loop3;
                                }
                            }

                            loop3:
                            ;

                        }
                        finally { DebugExitSubRule(3); }


                    }

                    retval.Stop = (IToken)input.LT(-1);

                    retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                    adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

                }
                catch (RecognitionException re)
                {
                    ReportError(re);
                    Recover(input, re);
                    retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

                }
                finally
                {
                    TraceOut("equalityExpression", 4);
                    LeaveRule("equalityExpression", 4);
                    Leave_equalityExpression();
                }
                DebugLocation(66, 1);
            }
            finally { DebugExitRule(GrammarFileName, "equalityExpression"); }
            return retval;

        }
        // $ANTLR end "equalityExpression"

        public class relationalExpression_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<CommonTree>
        {
            private CommonTree _tree;
            public CommonTree Tree { get { return _tree; } set { _tree = value; } }
            object IAstRuleReturnScope.Tree { get { return Tree; } }
        }

        partial void Enter_relationalExpression();
        partial void Leave_relationalExpression();

        // $ANTLR start "relationalExpression"
        // C:\\projects\\Expressions\\antlr\\Expression.g:73:1: relationalExpression : additiveExpression ( ( LT | LTEQ | GT | GTEQ ) additiveExpression )* ;
        [GrammarRule("relationalExpression")]
        private ExpressionParser.relationalExpression_return relationalExpression()
        {
            Enter_relationalExpression();
            EnterRule("relationalExpression", 5);
            TraceIn("relationalExpression", 5);
            ExpressionParser.relationalExpression_return retval = new ExpressionParser.relationalExpression_return();
            retval.Start = (IToken)input.LT(1);

            CommonTree root_0 = null;

            IToken set13 = null;
            ExpressionParser.additiveExpression_return additiveExpression12 = default(ExpressionParser.additiveExpression_return);
            ExpressionParser.additiveExpression_return additiveExpression14 = default(ExpressionParser.additiveExpression_return);

            CommonTree set13_tree = null;

            try
            {
                DebugEnterRule(GrammarFileName, "relationalExpression");
                DebugLocation(73, 1);
                try
                {
                    // C:\\projects\\Expressions\\antlr\\Expression.g:74:2: ( additiveExpression ( ( LT | LTEQ | GT | GTEQ ) additiveExpression )* )
                    DebugEnterAlt(1);
                    // C:\\projects\\Expressions\\antlr\\Expression.g:74:4: additiveExpression ( ( LT | LTEQ | GT | GTEQ ) additiveExpression )*
                    {
                        root_0 = (CommonTree)adaptor.Nil();

                        DebugLocation(74, 4);
                        PushFollow(Follow._additiveExpression_in_relationalExpression208);
                        additiveExpression12 = additiveExpression();
                        PopFollow();

                        adaptor.AddChild(root_0, additiveExpression12.Tree);
                        DebugLocation(74, 23);
                        // C:\\projects\\Expressions\\antlr\\Expression.g:74:23: ( ( LT | LTEQ | GT | GTEQ ) additiveExpression )*
                        try
                        {
                            DebugEnterSubRule(4);
                            while (true)
                            {
                                int alt4 = 2;
                                try
                                {
                                    DebugEnterDecision(4, decisionCanBacktrack[4]);
                                    int LA4_0 = input.LA(1);

                                    if (((LA4_0 >= LT && LA4_0 <= GTEQ)))
                                    {
                                        alt4 = 1;
                                    }


                                }
                                finally { DebugExitDecision(4); }
                                switch (alt4)
                                {
                                    case 1:
                                        DebugEnterAlt(1);
                                        // C:\\projects\\Expressions\\antlr\\Expression.g:74:25: ( LT | LTEQ | GT | GTEQ ) additiveExpression
                                        {
                                            DebugLocation(74, 25);
                                            set13 = (IToken)input.LT(1);
                                            set13 = (IToken)input.LT(1);
                                            if ((input.LA(1) >= LT && input.LA(1) <= GTEQ))
                                            {
                                                input.Consume();
                                                root_0 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(set13), root_0);
                                                state.errorRecovery = false;
                                            }
                                            else
                                            {
                                                MismatchedSetException mse = new MismatchedSetException(null, input);
                                                DebugRecognitionException(mse);
                                                throw mse;
                                            }

                                            DebugLocation(74, 44);
                                            PushFollow(Follow._additiveExpression_in_relationalExpression223);
                                            additiveExpression14 = additiveExpression();
                                            PopFollow();

                                            adaptor.AddChild(root_0, additiveExpression14.Tree);

                                        }
                                        break;

                                    default:
                                        goto loop4;
                                }
                            }

                            loop4:
                            ;

                        }
                        finally { DebugExitSubRule(4); }


                    }

                    retval.Stop = (IToken)input.LT(-1);

                    retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                    adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

                }
                catch (RecognitionException re)
                {
                    ReportError(re);
                    Recover(input, re);
                    retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

                }
                finally
                {
                    TraceOut("relationalExpression", 5);
                    LeaveRule("relationalExpression", 5);
                    Leave_relationalExpression();
                }
                DebugLocation(75, 1);
            }
            finally { DebugExitRule(GrammarFileName, "relationalExpression"); }
            return retval;

        }
        // $ANTLR end "relationalExpression"

        public class additiveExpression_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<CommonTree>
        {
            private CommonTree _tree;
            public CommonTree Tree { get { return _tree; } set { _tree = value; } }
            object IAstRuleReturnScope.Tree { get { return Tree; } }
        }

        partial void Enter_additiveExpression();
        partial void Leave_additiveExpression();

        // $ANTLR start "additiveExpression"
        // C:\\projects\\Expressions\\antlr\\Expression.g:82:1: additiveExpression : multiplicativeExpression ( ( PLUS | MINUS ) multiplicativeExpression )* ;
        [GrammarRule("additiveExpression")]
        private ExpressionParser.additiveExpression_return additiveExpression()
        {
            Enter_additiveExpression();
            EnterRule("additiveExpression", 6);
            TraceIn("additiveExpression", 6);
            ExpressionParser.additiveExpression_return retval = new ExpressionParser.additiveExpression_return();
            retval.Start = (IToken)input.LT(1);

            CommonTree root_0 = null;

            IToken set16 = null;
            ExpressionParser.multiplicativeExpression_return multiplicativeExpression15 = default(ExpressionParser.multiplicativeExpression_return);
            ExpressionParser.multiplicativeExpression_return multiplicativeExpression17 = default(ExpressionParser.multiplicativeExpression_return);

            CommonTree set16_tree = null;

            try
            {
                DebugEnterRule(GrammarFileName, "additiveExpression");
                DebugLocation(82, 1);
                try
                {
                    // C:\\projects\\Expressions\\antlr\\Expression.g:83:2: ( multiplicativeExpression ( ( PLUS | MINUS ) multiplicativeExpression )* )
                    DebugEnterAlt(1);
                    // C:\\projects\\Expressions\\antlr\\Expression.g:83:4: multiplicativeExpression ( ( PLUS | MINUS ) multiplicativeExpression )*
                    {
                        root_0 = (CommonTree)adaptor.Nil();

                        DebugLocation(83, 4);
                        PushFollow(Follow._multiplicativeExpression_in_additiveExpression266);
                        multiplicativeExpression15 = multiplicativeExpression();
                        PopFollow();

                        adaptor.AddChild(root_0, multiplicativeExpression15.Tree);
                        DebugLocation(83, 29);
                        // C:\\projects\\Expressions\\antlr\\Expression.g:83:29: ( ( PLUS | MINUS ) multiplicativeExpression )*
                        try
                        {
                            DebugEnterSubRule(5);
                            while (true)
                            {
                                int alt5 = 2;
                                try
                                {
                                    DebugEnterDecision(5, decisionCanBacktrack[5]);
                                    int LA5_0 = input.LA(1);

                                    if (((LA5_0 >= PLUS && LA5_0 <= MINUS)))
                                    {
                                        alt5 = 1;
                                    }


                                }
                                finally { DebugExitDecision(5); }
                                switch (alt5)
                                {
                                    case 1:
                                        DebugEnterAlt(1);
                                        // C:\\projects\\Expressions\\antlr\\Expression.g:83:31: ( PLUS | MINUS ) multiplicativeExpression
                                        {
                                            DebugLocation(83, 31);
                                            set16 = (IToken)input.LT(1);
                                            set16 = (IToken)input.LT(1);
                                            if ((input.LA(1) >= PLUS && input.LA(1) <= MINUS))
                                            {
                                                input.Consume();
                                                root_0 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(set16), root_0);
                                                state.errorRecovery = false;
                                            }
                                            else
                                            {
                                                MismatchedSetException mse = new MismatchedSetException(null, input);
                                                DebugRecognitionException(mse);
                                                throw mse;
                                            }

                                            DebugLocation(83, 45);
                                            PushFollow(Follow._multiplicativeExpression_in_additiveExpression277);
                                            multiplicativeExpression17 = multiplicativeExpression();
                                            PopFollow();

                                            adaptor.AddChild(root_0, multiplicativeExpression17.Tree);

                                        }
                                        break;

                                    default:
                                        goto loop5;
                                }
                            }

                            loop5:
                            ;

                        }
                        finally { DebugExitSubRule(5); }


                    }

                    retval.Stop = (IToken)input.LT(-1);

                    retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                    adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

                }
                catch (RecognitionException re)
                {
                    ReportError(re);
                    Recover(input, re);
                    retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

                }
                finally
                {
                    TraceOut("additiveExpression", 6);
                    LeaveRule("additiveExpression", 6);
                    Leave_additiveExpression();
                }
                DebugLocation(84, 1);
            }
            finally { DebugExitRule(GrammarFileName, "additiveExpression"); }
            return retval;

        }
        // $ANTLR end "additiveExpression"

        public class multiplicativeExpression_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<CommonTree>
        {
            private CommonTree _tree;
            public CommonTree Tree { get { return _tree; } set { _tree = value; } }
            object IAstRuleReturnScope.Tree { get { return Tree; } }
        }

        partial void Enter_multiplicativeExpression();
        partial void Leave_multiplicativeExpression();

        // $ANTLR start "multiplicativeExpression"
        // C:\\projects\\Expressions\\antlr\\Expression.g:89:1: multiplicativeExpression : powerExpression ( ( MULT | DIV | MOD ) powerExpression )* ;
        [GrammarRule("multiplicativeExpression")]
        private ExpressionParser.multiplicativeExpression_return multiplicativeExpression()
        {
            Enter_multiplicativeExpression();
            EnterRule("multiplicativeExpression", 7);
            TraceIn("multiplicativeExpression", 7);
            ExpressionParser.multiplicativeExpression_return retval = new ExpressionParser.multiplicativeExpression_return();
            retval.Start = (IToken)input.LT(1);

            CommonTree root_0 = null;

            IToken set19 = null;
            ExpressionParser.powerExpression_return powerExpression18 = default(ExpressionParser.powerExpression_return);
            ExpressionParser.powerExpression_return powerExpression20 = default(ExpressionParser.powerExpression_return);

            CommonTree set19_tree = null;

            try
            {
                DebugEnterRule(GrammarFileName, "multiplicativeExpression");
                DebugLocation(89, 1);
                try
                {
                    // C:\\projects\\Expressions\\antlr\\Expression.g:90:2: ( powerExpression ( ( MULT | DIV | MOD ) powerExpression )* )
                    DebugEnterAlt(1);
                    // C:\\projects\\Expressions\\antlr\\Expression.g:90:4: powerExpression ( ( MULT | DIV | MOD ) powerExpression )*
                    {
                        root_0 = (CommonTree)adaptor.Nil();

                        DebugLocation(90, 4);
                        PushFollow(Follow._powerExpression_in_multiplicativeExpression307);
                        powerExpression18 = powerExpression();
                        PopFollow();

                        adaptor.AddChild(root_0, powerExpression18.Tree);
                        DebugLocation(90, 20);
                        // C:\\projects\\Expressions\\antlr\\Expression.g:90:20: ( ( MULT | DIV | MOD ) powerExpression )*
                        try
                        {
                            DebugEnterSubRule(6);
                            while (true)
                            {
                                int alt6 = 2;
                                try
                                {
                                    DebugEnterDecision(6, decisionCanBacktrack[6]);
                                    int LA6_0 = input.LA(1);

                                    if (((LA6_0 >= MULT && LA6_0 <= MOD)))
                                    {
                                        alt6 = 1;
                                    }


                                }
                                finally { DebugExitDecision(6); }
                                switch (alt6)
                                {
                                    case 1:
                                        DebugEnterAlt(1);
                                        // C:\\projects\\Expressions\\antlr\\Expression.g:90:22: ( MULT | DIV | MOD ) powerExpression
                                        {
                                            DebugLocation(90, 22);
                                            set19 = (IToken)input.LT(1);
                                            set19 = (IToken)input.LT(1);
                                            if ((input.LA(1) >= MULT && input.LA(1) <= MOD))
                                            {
                                                input.Consume();
                                                root_0 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(set19), root_0);
                                                state.errorRecovery = false;
                                            }
                                            else
                                            {
                                                MismatchedSetException mse = new MismatchedSetException(null, input);
                                                DebugRecognitionException(mse);
                                                throw mse;
                                            }

                                            DebugLocation(90, 38);
                                            PushFollow(Follow._powerExpression_in_multiplicativeExpression320);
                                            powerExpression20 = powerExpression();
                                            PopFollow();

                                            adaptor.AddChild(root_0, powerExpression20.Tree);

                                        }
                                        break;

                                    default:
                                        goto loop6;
                                }
                            }

                            loop6:
                            ;

                        }
                        finally { DebugExitSubRule(6); }


                    }

                    retval.Stop = (IToken)input.LT(-1);

                    retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                    adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

                }
                catch (RecognitionException re)
                {
                    ReportError(re);
                    Recover(input, re);
                    retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

                }
                finally
                {
                    TraceOut("multiplicativeExpression", 7);
                    LeaveRule("multiplicativeExpression", 7);
                    Leave_multiplicativeExpression();
                }
                DebugLocation(91, 1);
            }
            finally { DebugExitRule(GrammarFileName, "multiplicativeExpression"); }
            return retval;

        }
        // $ANTLR end "multiplicativeExpression"

        public class powerExpression_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<CommonTree>
        {
            private CommonTree _tree;
            public CommonTree Tree { get { return _tree; } set { _tree = value; } }
            object IAstRuleReturnScope.Tree { get { return Tree; } }
        }

        partial void Enter_powerExpression();
        partial void Leave_powerExpression();

        // $ANTLR start "powerExpression"
        // C:\\projects\\Expressions\\antlr\\Expression.g:97:1: powerExpression : unaryExpression ( POW unaryExpression )* ;
        [GrammarRule("powerExpression")]
        private ExpressionParser.powerExpression_return powerExpression()
        {
            Enter_powerExpression();
            EnterRule("powerExpression", 8);
            TraceIn("powerExpression", 8);
            ExpressionParser.powerExpression_return retval = new ExpressionParser.powerExpression_return();
            retval.Start = (IToken)input.LT(1);

            CommonTree root_0 = null;

            IToken POW22 = null;
            ExpressionParser.unaryExpression_return unaryExpression21 = default(ExpressionParser.unaryExpression_return);
            ExpressionParser.unaryExpression_return unaryExpression23 = default(ExpressionParser.unaryExpression_return);

            CommonTree POW22_tree = null;

            try
            {
                DebugEnterRule(GrammarFileName, "powerExpression");
                DebugLocation(97, 1);
                try
                {
                    // C:\\projects\\Expressions\\antlr\\Expression.g:98:2: ( unaryExpression ( POW unaryExpression )* )
                    DebugEnterAlt(1);
                    // C:\\projects\\Expressions\\antlr\\Expression.g:98:4: unaryExpression ( POW unaryExpression )*
                    {
                        root_0 = (CommonTree)adaptor.Nil();

                        DebugLocation(98, 4);
                        PushFollow(Follow._unaryExpression_in_powerExpression358);
                        unaryExpression21 = unaryExpression();
                        PopFollow();

                        adaptor.AddChild(root_0, unaryExpression21.Tree);
                        DebugLocation(98, 20);
                        // C:\\projects\\Expressions\\antlr\\Expression.g:98:20: ( POW unaryExpression )*
                        try
                        {
                            DebugEnterSubRule(7);
                            while (true)
                            {
                                int alt7 = 2;
                                try
                                {
                                    DebugEnterDecision(7, decisionCanBacktrack[7]);
                                    int LA7_0 = input.LA(1);

                                    if ((LA7_0 == POW))
                                    {
                                        alt7 = 1;
                                    }


                                }
                                finally { DebugExitDecision(7); }
                                switch (alt7)
                                {
                                    case 1:
                                        DebugEnterAlt(1);
                                        // C:\\projects\\Expressions\\antlr\\Expression.g:98:22: POW unaryExpression
                                        {
                                            DebugLocation(98, 25);
                                            POW22 = (IToken)Match(input, POW, Follow._POW_in_powerExpression362);
                                            POW22_tree = (CommonTree)adaptor.Create(POW22);
                                            root_0 = (CommonTree)adaptor.BecomeRoot(POW22_tree, root_0);

                                            DebugLocation(98, 27);
                                            PushFollow(Follow._unaryExpression_in_powerExpression365);
                                            unaryExpression23 = unaryExpression();
                                            PopFollow();

                                            adaptor.AddChild(root_0, unaryExpression23.Tree);

                                        }
                                        break;

                                    default:
                                        goto loop7;
                                }
                            }

                            loop7:
                            ;

                        }
                        finally { DebugExitSubRule(7); }


                    }

                    retval.Stop = (IToken)input.LT(-1);

                    retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                    adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

                }
                catch (RecognitionException re)
                {
                    ReportError(re);
                    Recover(input, re);
                    retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

                }
                finally
                {
                    TraceOut("powerExpression", 8);
                    LeaveRule("powerExpression", 8);
                    Leave_powerExpression();
                }
                DebugLocation(99, 1);
            }
            finally { DebugExitRule(GrammarFileName, "powerExpression"); }
            return retval;

        }
        // $ANTLR end "powerExpression"

        public class unaryExpression_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<CommonTree>
        {
            private CommonTree _tree;
            public CommonTree Tree { get { return _tree; } set { _tree = value; } }
            object IAstRuleReturnScope.Tree { get { return Tree; } }
        }

        partial void Enter_unaryExpression();
        partial void Leave_unaryExpression();

        // $ANTLR start "unaryExpression"
        // C:\\projects\\Expressions\\antlr\\Expression.g:103:1: unaryExpression : ( primaryExpression | NOT primaryExpression | MINUS primaryExpression -> ^( NEGATE primaryExpression ) );
        [GrammarRule("unaryExpression")]
        private ExpressionParser.unaryExpression_return unaryExpression()
        {
            Enter_unaryExpression();
            EnterRule("unaryExpression", 9);
            TraceIn("unaryExpression", 9);
            ExpressionParser.unaryExpression_return retval = new ExpressionParser.unaryExpression_return();
            retval.Start = (IToken)input.LT(1);

            CommonTree root_0 = null;

            IToken NOT25 = null;
            IToken MINUS27 = null;
            ExpressionParser.primaryExpression_return primaryExpression24 = default(ExpressionParser.primaryExpression_return);
            ExpressionParser.primaryExpression_return primaryExpression26 = default(ExpressionParser.primaryExpression_return);
            ExpressionParser.primaryExpression_return primaryExpression28 = default(ExpressionParser.primaryExpression_return);

            CommonTree NOT25_tree = null;
            CommonTree MINUS27_tree = null;
            RewriteRuleTokenStream stream_MINUS = new RewriteRuleTokenStream(adaptor, "token MINUS");
            RewriteRuleSubtreeStream stream_primaryExpression = new RewriteRuleSubtreeStream(adaptor, "rule primaryExpression");
            try
            {
                DebugEnterRule(GrammarFileName, "unaryExpression");
                DebugLocation(103, 4);
                try
                {
                    // C:\\projects\\Expressions\\antlr\\Expression.g:104:2: ( primaryExpression | NOT primaryExpression | MINUS primaryExpression -> ^( NEGATE primaryExpression ) )
                    int alt8 = 3;
                    try
                    {
                        DebugEnterDecision(8, decisionCanBacktrack[8]);
                        switch (input.LA(1))
                        {
                            case STRING:
                            case INTEGER:
                            case FLOAT:
                            case REF:
                            case REFRANGE:
                            case PAR:
                            case IDENT:
                            case 34:
                                {
                                    alt8 = 1;
                                }
                                break;
                            case NOT:
                                {
                                    alt8 = 2;
                                }
                                break;
                            case MINUS:
                                {
                                    alt8 = 3;
                                }
                                break;
                            default:
                                {
                                    NoViableAltException nvae = new NoViableAltException("", 8, 0, input);

                                    DebugRecognitionException(nvae);
                                    throw nvae;
                                }
                        }

                    }
                    finally { DebugExitDecision(8); }
                    switch (alt8)
                    {
                        case 1:
                            DebugEnterAlt(1);
                            // C:\\projects\\Expressions\\antlr\\Expression.g:104:4: primaryExpression
                            {
                                root_0 = (CommonTree)adaptor.Nil();

                                DebugLocation(104, 4);
                                PushFollow(Follow._primaryExpression_in_unaryExpression388);
                                primaryExpression24 = primaryExpression();
                                PopFollow();

                                adaptor.AddChild(root_0, primaryExpression24.Tree);

                            }
                            break;
                        case 2:
                            DebugEnterAlt(2);
                            // C:\\projects\\Expressions\\antlr\\Expression.g:105:8: NOT primaryExpression
                            {
                                root_0 = (CommonTree)adaptor.Nil();

                                DebugLocation(105, 11);
                                NOT25 = (IToken)Match(input, NOT, Follow._NOT_in_unaryExpression397);
                                NOT25_tree = (CommonTree)adaptor.Create(NOT25);
                                root_0 = (CommonTree)adaptor.BecomeRoot(NOT25_tree, root_0);

                                DebugLocation(105, 13);
                                PushFollow(Follow._primaryExpression_in_unaryExpression400);
                                primaryExpression26 = primaryExpression();
                                PopFollow();

                                adaptor.AddChild(root_0, primaryExpression26.Tree);

                            }
                            break;
                        case 3:
                            DebugEnterAlt(3);
                            // C:\\projects\\Expressions\\antlr\\Expression.g:106:8: MINUS primaryExpression
                            {
                                DebugLocation(106, 8);
                                MINUS27 = (IToken)Match(input, MINUS, Follow._MINUS_in_unaryExpression409);
                                stream_MINUS.Add(MINUS27);

                                DebugLocation(106, 14);
                                PushFollow(Follow._primaryExpression_in_unaryExpression411);
                                primaryExpression28 = primaryExpression();
                                PopFollow();

                                stream_primaryExpression.Add(primaryExpression28.Tree);


                                {
                                    // AST REWRITE
                                    // elements: primaryExpression
                                    // token labels: 
                                    // rule labels: retval
                                    // token list labels: 
                                    // rule list labels: 
                                    // wildcard labels: 
                                    retval.Tree = root_0;
                                    RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.Tree : null);

                                    root_0 = (CommonTree)adaptor.Nil();
                                    // 106:32: -> ^( NEGATE primaryExpression )
                                    {
                                        DebugLocation(106, 35);
                                        // C:\\projects\\Expressions\\antlr\\Expression.g:106:35: ^( NEGATE primaryExpression )
                                        {
                                            CommonTree root_1 = (CommonTree)adaptor.Nil();
                                            DebugLocation(106, 37);
                                            root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(NEGATE, "NEGATE"), root_1);

                                            DebugLocation(106, 44);
                                            adaptor.AddChild(root_1, stream_primaryExpression.NextTree());

                                            adaptor.AddChild(root_0, root_1);
                                        }

                                    }

                                    retval.Tree = root_0;
                                }

                            }
                            break;

                    }
                    retval.Stop = (IToken)input.LT(-1);

                    retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                    adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

                }
                catch (RecognitionException re)
                {
                    ReportError(re);
                    Recover(input, re);
                    retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

                }
                finally
                {
                    TraceOut("unaryExpression", 9);
                    LeaveRule("unaryExpression", 9);
                    Leave_unaryExpression();
                }
                DebugLocation(107, 4);
            }
            finally { DebugExitRule(GrammarFileName, "unaryExpression"); }
            return retval;

        }
        // $ANTLR end "unaryExpression"

        public class primaryExpression_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<CommonTree>
        {
            private CommonTree _tree;
            public CommonTree Tree { get { return _tree; } set { _tree = value; } }
            object IAstRuleReturnScope.Tree { get { return Tree; } }
        }

        partial void Enter_primaryExpression();
        partial void Leave_primaryExpression();

        // $ANTLR start "primaryExpression"
        // C:\\projects\\Expressions\\antlr\\Expression.g:111:1: primaryExpression : ( '(' logicalExpression ')' | value );
        [GrammarRule("primaryExpression")]
        private ExpressionParser.primaryExpression_return primaryExpression()
        {
            Enter_primaryExpression();
            EnterRule("primaryExpression", 10);
            TraceIn("primaryExpression", 10);
            ExpressionParser.primaryExpression_return retval = new ExpressionParser.primaryExpression_return();
            retval.Start = (IToken)input.LT(1);

            CommonTree root_0 = null;

            IToken char_literal29 = null;
            IToken char_literal31 = null;
            ExpressionParser.logicalExpression_return logicalExpression30 = default(ExpressionParser.logicalExpression_return);
            ExpressionParser.value_return value32 = default(ExpressionParser.value_return);

            CommonTree char_literal29_tree = null;
            CommonTree char_literal31_tree = null;

            try
            {
                DebugEnterRule(GrammarFileName, "primaryExpression");
                DebugLocation(111, 1);
                try
                {
                    // C:\\projects\\Expressions\\antlr\\Expression.g:112:2: ( '(' logicalExpression ')' | value )
                    int alt9 = 2;
                    try
                    {
                        DebugEnterDecision(9, decisionCanBacktrack[9]);
                        int LA9_0 = input.LA(1);

                        if ((LA9_0 == 34))
                        {
                            alt9 = 1;
                        }
                        else if ((LA9_0 == STRING || (LA9_0 >= INTEGER && LA9_0 <= PAR) || LA9_0 == IDENT))
                        {
                            alt9 = 2;
                        }
                        else
                        {
                            NoViableAltException nvae = new NoViableAltException("", 9, 0, input);

                            DebugRecognitionException(nvae);
                            throw nvae;
                        }
                    }
                    finally { DebugExitDecision(9); }
                    switch (alt9)
                    {
                        case 1:
                            DebugEnterAlt(1);
                            // C:\\projects\\Expressions\\antlr\\Expression.g:112:4: '(' logicalExpression ')'
                            {
                                root_0 = (CommonTree)adaptor.Nil();

                                DebugLocation(112, 7);
                                char_literal29 = (IToken)Match(input, 34, Follow._34_in_primaryExpression447);
                                DebugLocation(112, 9);
                                PushFollow(Follow._logicalExpression_in_primaryExpression450);
                                logicalExpression30 = logicalExpression();
                                PopFollow();

                                adaptor.AddChild(root_0, logicalExpression30.Tree);
                                DebugLocation(112, 30);
                                char_literal31 = (IToken)Match(input, 35, Follow._35_in_primaryExpression452);

                            }
                            break;
                        case 2:
                            DebugEnterAlt(2);
                            // C:\\projects\\Expressions\\antlr\\Expression.g:113:4: value
                            {
                                root_0 = (CommonTree)adaptor.Nil();

                                DebugLocation(113, 4);
                                PushFollow(Follow._value_in_primaryExpression458);
                                value32 = value();
                                PopFollow();

                                adaptor.AddChild(root_0, value32.Tree);

                            }
                            break;

                    }
                    retval.Stop = (IToken)input.LT(-1);

                    retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                    adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

                }
                catch (RecognitionException re)
                {
                    ReportError(re);
                    Recover(input, re);
                    retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

                }
                finally
                {
                    TraceOut("primaryExpression", 10);
                    LeaveRule("primaryExpression", 10);
                    Leave_primaryExpression();
                }
                DebugLocation(114, 1);
            }
            finally { DebugExitRule(GrammarFileName, "primaryExpression"); }
            return retval;

        }
        // $ANTLR end "primaryExpression"

        public class value_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<CommonTree>
        {
            private CommonTree _tree;
            public CommonTree Tree { get { return _tree; } set { _tree = value; } }
            object IAstRuleReturnScope.Tree { get { return Tree; } }
        }

        partial void Enter_value();
        partial void Leave_value();

        // $ANTLR start "value"
        // C:\\projects\\Expressions\\antlr\\Expression.g:116:1: value : ( INTEGER | FLOAT | STRING | function | reference | rangereference | par );
        [GrammarRule("value")]
        private ExpressionParser.value_return value()
        {
            Enter_value();
            EnterRule("value", 11);
            TraceIn("value", 11);
            ExpressionParser.value_return retval = new ExpressionParser.value_return();
            retval.Start = (IToken)input.LT(1);

            CommonTree root_0 = null;

            IToken INTEGER33 = null;
            IToken FLOAT34 = null;
            IToken STRING35 = null;
            ExpressionParser.function_return function36 = default(ExpressionParser.function_return);
            ExpressionParser.reference_return reference37 = default(ExpressionParser.reference_return);
            ExpressionParser.rangereference_return rangereference38 = default(ExpressionParser.rangereference_return);
            ExpressionParser.par_return par39 = default(ExpressionParser.par_return);

            CommonTree INTEGER33_tree = null;
            CommonTree FLOAT34_tree = null;
            CommonTree STRING35_tree = null;

            try
            {
                DebugEnterRule(GrammarFileName, "value");
                DebugLocation(116, 1);
                try
                {
                    // C:\\projects\\Expressions\\antlr\\Expression.g:117:2: ( INTEGER | FLOAT | STRING | function | reference | rangereference | par )
                    int alt10 = 7;
                    try
                    {
                        DebugEnterDecision(10, decisionCanBacktrack[10]);
                        switch (input.LA(1))
                        {
                            case INTEGER:
                                {
                                    alt10 = 1;
                                }
                                break;
                            case FLOAT:
                                {
                                    alt10 = 2;
                                }
                                break;
                            case STRING:
                                {
                                    alt10 = 3;
                                }
                                break;
                            case IDENT:
                                {
                                    alt10 = 4;
                                }
                                break;
                            case REF:
                                {
                                    alt10 = 5;
                                }
                                break;
                            case REFRANGE:
                                {
                                    alt10 = 6;
                                }
                                break;
                            case PAR:
                                {
                                    alt10 = 7;
                                }
                                break;
                            default:
                                {
                                    NoViableAltException nvae = new NoViableAltException("", 10, 0, input);

                                    DebugRecognitionException(nvae);
                                    throw nvae;
                                }
                        }

                    }
                    finally { DebugExitDecision(10); }
                    switch (alt10)
                    {
                        case 1:
                            DebugEnterAlt(1);
                            // C:\\projects\\Expressions\\antlr\\Expression.g:117:5: INTEGER
                            {
                                root_0 = (CommonTree)adaptor.Nil();

                                DebugLocation(117, 5);
                                INTEGER33 = (IToken)Match(input, INTEGER, Follow._INTEGER_in_value472);
                                INTEGER33_tree = (CommonTree)adaptor.Create(INTEGER33);
                                adaptor.AddChild(root_0, INTEGER33_tree);


                            }
                            break;
                        case 2:
                            DebugEnterAlt(2);
                            // C:\\projects\\Expressions\\antlr\\Expression.g:118:4: FLOAT
                            {
                                root_0 = (CommonTree)adaptor.Nil();

                                DebugLocation(118, 4);
                                FLOAT34 = (IToken)Match(input, FLOAT, Follow._FLOAT_in_value477);
                                FLOAT34_tree = (CommonTree)adaptor.Create(FLOAT34);
                                adaptor.AddChild(root_0, FLOAT34_tree);


                            }
                            break;
                        case 3:
                            DebugEnterAlt(3);
                            // C:\\projects\\Expressions\\antlr\\Expression.g:119:4: STRING
                            {
                                root_0 = (CommonTree)adaptor.Nil();

                                DebugLocation(119, 4);
                                STRING35 = (IToken)Match(input, STRING, Follow._STRING_in_value482);
                                STRING35_tree = (CommonTree)adaptor.Create(STRING35);
                                adaptor.AddChild(root_0, STRING35_tree);


                            }
                            break;
                        case 4:
                            DebugEnterAlt(4);
                            // C:\\projects\\Expressions\\antlr\\Expression.g:120:4: function
                            {
                                root_0 = (CommonTree)adaptor.Nil();

                                DebugLocation(120, 4);
                                PushFollow(Follow._function_in_value487);
                                function36 = function();
                                PopFollow();

                                adaptor.AddChild(root_0, function36.Tree);

                            }
                            break;
                        case 5:
                            DebugEnterAlt(5);
                            // C:\\projects\\Expressions\\antlr\\Expression.g:121:4: reference
                            {
                                root_0 = (CommonTree)adaptor.Nil();

                                DebugLocation(121, 4);
                                PushFollow(Follow._reference_in_value492);
                                reference37 = reference();
                                PopFollow();

                                adaptor.AddChild(root_0, reference37.Tree);

                            }
                            break;
                        case 6:
                            DebugEnterAlt(6);
                            // C:\\projects\\Expressions\\antlr\\Expression.g:122:4: rangereference
                            {
                                root_0 = (CommonTree)adaptor.Nil();

                                DebugLocation(122, 4);
                                PushFollow(Follow._rangereference_in_value497);
                                rangereference38 = rangereference();
                                PopFollow();

                                adaptor.AddChild(root_0, rangereference38.Tree);

                            }
                            break;
                        case 7:
                            DebugEnterAlt(7);
                            // C:\\projects\\Expressions\\antlr\\Expression.g:123:4: par
                            {
                                root_0 = (CommonTree)adaptor.Nil();

                                DebugLocation(123, 4);
                                PushFollow(Follow._par_in_value502);
                                par39 = par();
                                PopFollow();

                                adaptor.AddChild(root_0, par39.Tree);

                            }
                            break;

                    }
                    retval.Stop = (IToken)input.LT(-1);

                    retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                    adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

                }
                catch (RecognitionException re)
                {
                    ReportError(re);
                    Recover(input, re);
                    retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

                }
                finally
                {
                    TraceOut("value", 11);
                    LeaveRule("value", 11);
                    Leave_value();
                }
                DebugLocation(124, 1);
            }
            finally { DebugExitRule(GrammarFileName, "value"); }
            return retval;

        }
        // $ANTLR end "value"

        public class reference_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<CommonTree>
        {
            private CommonTree _tree;
            public CommonTree Tree { get { return _tree; } set { _tree = value; } }
            object IAstRuleReturnScope.Tree { get { return Tree; } }
        }

        partial void Enter_reference();
        partial void Leave_reference();

        // $ANTLR start "reference"
        // C:\\projects\\Expressions\\antlr\\Expression.g:127:1: reference : REF -> ^( REFERENCE ( REF )? ) ;
        [GrammarRule("reference")]
        private ExpressionParser.reference_return reference()
        {
            Enter_reference();
            EnterRule("reference", 12);
            TraceIn("reference", 12);
            ExpressionParser.reference_return retval = new ExpressionParser.reference_return();
            retval.Start = (IToken)input.LT(1);

            CommonTree root_0 = null;

            IToken REF40 = null;

            CommonTree REF40_tree = null;
            RewriteRuleTokenStream stream_REF = new RewriteRuleTokenStream(adaptor, "token REF");

            try
            {
                DebugEnterRule(GrammarFileName, "reference");
                DebugLocation(127, 1);
                try
                {
                    // C:\\projects\\Expressions\\antlr\\Expression.g:128:2: ( REF -> ^( REFERENCE ( REF )? ) )
                    DebugEnterAlt(1);
                    // C:\\projects\\Expressions\\antlr\\Expression.g:128:4: REF
                    {
                        DebugLocation(128, 4);
                        REF40 = (IToken)Match(input, REF, Follow._REF_in_reference514);
                        stream_REF.Add(REF40);



                        {
                            // AST REWRITE
                            // elements: REF
                            // token labels: 
                            // rule labels: retval
                            // token list labels: 
                            // rule list labels: 
                            // wildcard labels: 
                            retval.Tree = root_0;
                            RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.Tree : null);

                            root_0 = (CommonTree)adaptor.Nil();
                            // 128:9: -> ^( REFERENCE ( REF )? )
                            {
                                DebugLocation(128, 12);
                                // C:\\projects\\Expressions\\antlr\\Expression.g:128:12: ^( REFERENCE ( REF )? )
                                {
                                    CommonTree root_1 = (CommonTree)adaptor.Nil();
                                    DebugLocation(128, 14);
                                    root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(REFERENCE, "REFERENCE"), root_1);

                                    DebugLocation(128, 24);
                                    // C:\\projects\\Expressions\\antlr\\Expression.g:128:24: ( REF )?
                                    if (stream_REF.HasNext)
                                    {
                                        DebugLocation(128, 24);
                                        adaptor.AddChild(root_1, stream_REF.NextNode());

                                    }
                                    stream_REF.Reset();

                                    adaptor.AddChild(root_0, root_1);
                                }

                            }

                            retval.Tree = root_0;
                        }

                    }

                    retval.Stop = (IToken)input.LT(-1);

                    retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                    adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

                }
                catch (RecognitionException re)
                {
                    ReportError(re);
                    Recover(input, re);
                    retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

                }
                finally
                {
                    TraceOut("reference", 12);
                    LeaveRule("reference", 12);
                    Leave_reference();
                }
                DebugLocation(129, 1);
            }
            finally { DebugExitRule(GrammarFileName, "reference"); }
            return retval;

        }
        // $ANTLR end "reference"

        public class rangereference_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<CommonTree>
        {
            private CommonTree _tree;
            public CommonTree Tree { get { return _tree; } set { _tree = value; } }
            object IAstRuleReturnScope.Tree { get { return Tree; } }
        }

        partial void Enter_rangereference();
        partial void Leave_rangereference();

        // $ANTLR start "rangereference"
        // C:\\projects\\Expressions\\antlr\\Expression.g:131:1: rangereference : REFRANGE -> ^( RANGEREFERENCE ( REFRANGE )? ) ;
        [GrammarRule("rangereference")]
        private ExpressionParser.rangereference_return rangereference()
        {
            Enter_rangereference();
            EnterRule("rangereference", 13);
            TraceIn("rangereference", 13);
            ExpressionParser.rangereference_return retval = new ExpressionParser.rangereference_return();
            retval.Start = (IToken)input.LT(1);

            CommonTree root_0 = null;

            IToken REFRANGE41 = null;

            CommonTree REFRANGE41_tree = null;
            RewriteRuleTokenStream stream_REFRANGE = new RewriteRuleTokenStream(adaptor, "token REFRANGE");

            try
            {
                DebugEnterRule(GrammarFileName, "rangereference");
                DebugLocation(131, 1);
                try
                {
                    // C:\\projects\\Expressions\\antlr\\Expression.g:132:2: ( REFRANGE -> ^( RANGEREFERENCE ( REFRANGE )? ) )
                    DebugEnterAlt(1);
                    // C:\\projects\\Expressions\\antlr\\Expression.g:132:4: REFRANGE
                    {
                        DebugLocation(132, 4);
                        REFRANGE41 = (IToken)Match(input, REFRANGE, Follow._REFRANGE_in_rangereference536);
                        stream_REFRANGE.Add(REFRANGE41);



                        {
                            // AST REWRITE
                            // elements: REFRANGE
                            // token labels: 
                            // rule labels: retval
                            // token list labels: 
                            // rule list labels: 
                            // wildcard labels: 
                            retval.Tree = root_0;
                            RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.Tree : null);

                            root_0 = (CommonTree)adaptor.Nil();
                            // 132:13: -> ^( RANGEREFERENCE ( REFRANGE )? )
                            {
                                DebugLocation(132, 16);
                                // C:\\projects\\Expressions\\antlr\\Expression.g:132:16: ^( RANGEREFERENCE ( REFRANGE )? )
                                {
                                    CommonTree root_1 = (CommonTree)adaptor.Nil();
                                    DebugLocation(132, 18);
                                    root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(RANGEREFERENCE, "RANGEREFERENCE"), root_1);

                                    DebugLocation(132, 33);
                                    // C:\\projects\\Expressions\\antlr\\Expression.g:132:33: ( REFRANGE )?
                                    if (stream_REFRANGE.HasNext)
                                    {
                                        DebugLocation(132, 33);
                                        adaptor.AddChild(root_1, stream_REFRANGE.NextNode());

                                    }
                                    stream_REFRANGE.Reset();

                                    adaptor.AddChild(root_0, root_1);
                                }

                            }

                            retval.Tree = root_0;
                        }

                    }

                    retval.Stop = (IToken)input.LT(-1);

                    retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                    adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

                }
                catch (RecognitionException re)
                {
                    ReportError(re);
                    Recover(input, re);
                    retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

                }
                finally
                {
                    TraceOut("rangereference", 13);
                    LeaveRule("rangereference", 13);
                    Leave_rangereference();
                }
                DebugLocation(133, 1);
            }
            finally { DebugExitRule(GrammarFileName, "rangereference"); }
            return retval;

        }
        // $ANTLR end "rangereference"

        public class par_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<CommonTree>
        {
            private CommonTree _tree;
            public CommonTree Tree { get { return _tree; } set { _tree = value; } }
            object IAstRuleReturnScope.Tree { get { return Tree; } }
        }

        partial void Enter_par();
        partial void Leave_par();

        // $ANTLR start "par"
        // C:\\projects\\Expressions\\antlr\\Expression.g:135:1: par : PAR -> ^( PARAM ( PAR )? ) ;
        [GrammarRule("par")]
        public ExpressionParser.par_return par()
        {
            Enter_par();
            EnterRule("par", 14);
            TraceIn("par", 14);
            ExpressionParser.par_return retval = new ExpressionParser.par_return();
            retval.Start = (IToken)input.LT(1);

            CommonTree root_0 = null;

            IToken PAR42 = null;

            CommonTree PAR42_tree = null;
            RewriteRuleTokenStream stream_PAR = new RewriteRuleTokenStream(adaptor, "token PAR");

            try
            {
                DebugEnterRule(GrammarFileName, "par");
                DebugLocation(135, 1);
                try
                {
                    // C:\\projects\\Expressions\\antlr\\Expression.g:135:5: ( PAR -> ^( PARAM ( PAR )? ) )
                    DebugEnterAlt(1);
                    // C:\\projects\\Expressions\\antlr\\Expression.g:135:7: PAR
                    {
                        DebugLocation(135, 7);
                        PAR42 = (IToken)Match(input, PAR, Follow._PAR_in_par556);
                        stream_PAR.Add(PAR42);



                        {
                            // AST REWRITE
                            // elements: PAR
                            // token labels: 
                            // rule labels: retval
                            // token list labels: 
                            // rule list labels: 
                            // wildcard labels: 
                            retval.Tree = root_0;
                            RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.Tree : null);

                            root_0 = (CommonTree)adaptor.Nil();
                            // 135:12: -> ^( PARAM ( PAR )? )
                            {
                                DebugLocation(135, 15);
                                // C:\\projects\\Expressions\\antlr\\Expression.g:135:15: ^( PARAM ( PAR )? )
                                {
                                    CommonTree root_1 = (CommonTree)adaptor.Nil();
                                    DebugLocation(135, 17);
                                    root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(PARAM, "PARAM"), root_1);

                                    DebugLocation(135, 23);
                                    // C:\\projects\\Expressions\\antlr\\Expression.g:135:23: ( PAR )?
                                    if (stream_PAR.HasNext)
                                    {
                                        DebugLocation(135, 23);
                                        adaptor.AddChild(root_1, stream_PAR.NextNode());

                                    }
                                    stream_PAR.Reset();

                                    adaptor.AddChild(root_0, root_1);
                                }

                            }

                            retval.Tree = root_0;
                        }

                    }

                    retval.Stop = (IToken)input.LT(-1);

                    retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                    adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

                }
                catch (RecognitionException re)
                {
                    ReportError(re);
                    Recover(input, re);
                    retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

                }
                finally
                {
                    TraceOut("par", 14);
                    LeaveRule("par", 14);
                    Leave_par();
                }
                DebugLocation(136, 1);
            }
            finally { DebugExitRule(GrammarFileName, "par"); }
            return retval;

        }
        // $ANTLR end "par"

        public class function_return : ParserRuleReturnScope<IToken>, IAstRuleReturnScope<CommonTree>
        {
            private CommonTree _tree;
            public CommonTree Tree { get { return _tree; } set { _tree = value; } }
            object IAstRuleReturnScope.Tree { get { return Tree; } }
        }

        partial void Enter_function();
        partial void Leave_function();

        // $ANTLR start "function"
        // C:\\projects\\Expressions\\antlr\\Expression.g:163:1: function : IDENT '(' ( logicalExpression ( ',' logicalExpression )* )? ')' -> ^( IDENT ( logicalExpression )* ) ;
        [GrammarRule("function")]
        private ExpressionParser.function_return function()
        {
            Enter_function();
            EnterRule("function", 15);
            TraceIn("function", 15);
            ExpressionParser.function_return retval = new ExpressionParser.function_return();
            retval.Start = (IToken)input.LT(1);

            CommonTree root_0 = null;

            IToken IDENT43 = null;
            IToken char_literal44 = null;
            IToken char_literal46 = null;
            IToken char_literal48 = null;
            ExpressionParser.logicalExpression_return logicalExpression45 = default(ExpressionParser.logicalExpression_return);
            ExpressionParser.logicalExpression_return logicalExpression47 = default(ExpressionParser.logicalExpression_return);

            CommonTree IDENT43_tree = null;
            CommonTree char_literal44_tree = null;
            CommonTree char_literal46_tree = null;
            CommonTree char_literal48_tree = null;
            RewriteRuleTokenStream stream_IDENT = new RewriteRuleTokenStream(adaptor, "token IDENT");
            RewriteRuleTokenStream stream_35 = new RewriteRuleTokenStream(adaptor, "token 35");
            RewriteRuleTokenStream stream_36 = new RewriteRuleTokenStream(adaptor, "token 36");
            RewriteRuleTokenStream stream_34 = new RewriteRuleTokenStream(adaptor, "token 34");
            RewriteRuleSubtreeStream stream_logicalExpression = new RewriteRuleSubtreeStream(adaptor, "rule logicalExpression");
            try
            {
                DebugEnterRule(GrammarFileName, "function");
                DebugLocation(163, 1);
                try
                {
                    // C:\\projects\\Expressions\\antlr\\Expression.g:164:2: ( IDENT '(' ( logicalExpression ( ',' logicalExpression )* )? ')' -> ^( IDENT ( logicalExpression )* ) )
                    DebugEnterAlt(1);
                    // C:\\projects\\Expressions\\antlr\\Expression.g:164:4: IDENT '(' ( logicalExpression ( ',' logicalExpression )* )? ')'
                    {
                        DebugLocation(164, 4);
                        IDENT43 = (IToken)Match(input, IDENT, Follow._IDENT_in_function736);
                        stream_IDENT.Add(IDENT43);

                        DebugLocation(164, 10);
                        char_literal44 = (IToken)Match(input, 34, Follow._34_in_function738);
                        stream_34.Add(char_literal44);

                        DebugLocation(164, 14);
                        // C:\\projects\\Expressions\\antlr\\Expression.g:164:14: ( logicalExpression ( ',' logicalExpression )* )?
                        int alt12 = 2;
                        try
                        {
                            DebugEnterSubRule(12);
                            try
                            {
                                DebugEnterDecision(12, decisionCanBacktrack[12]);
                                int LA12_0 = input.LA(1);

                                if ((LA12_0 == STRING || LA12_0 == MINUS || (LA12_0 >= NOT && LA12_0 <= PAR) || LA12_0 == IDENT || LA12_0 == 34))
                                {
                                    alt12 = 1;
                                }
                            }
                            finally { DebugExitDecision(12); }
                            switch (alt12)
                            {
                                case 1:
                                    DebugEnterAlt(1);
                                    // C:\\projects\\Expressions\\antlr\\Expression.g:164:16: logicalExpression ( ',' logicalExpression )*
                                    {
                                        DebugLocation(164, 16);
                                        PushFollow(Follow._logicalExpression_in_function742);
                                        logicalExpression45 = logicalExpression();
                                        PopFollow();

                                        stream_logicalExpression.Add(logicalExpression45.Tree);
                                        DebugLocation(164, 34);
                                        // C:\\projects\\Expressions\\antlr\\Expression.g:164:34: ( ',' logicalExpression )*
                                        try
                                        {
                                            DebugEnterSubRule(11);
                                            while (true)
                                            {
                                                int alt11 = 2;
                                                try
                                                {
                                                    DebugEnterDecision(11, decisionCanBacktrack[11]);
                                                    int LA11_0 = input.LA(1);

                                                    if ((LA11_0 == 36))
                                                    {
                                                        alt11 = 1;
                                                    }


                                                }
                                                finally { DebugExitDecision(11); }
                                                switch (alt11)
                                                {
                                                    case 1:
                                                        DebugEnterAlt(1);
                                                        // C:\\projects\\Expressions\\antlr\\Expression.g:164:35: ',' logicalExpression
                                                        {
                                                            DebugLocation(164, 35);
                                                            char_literal46 = (IToken)Match(input, 36, Follow._36_in_function745);
                                                            stream_36.Add(char_literal46);

                                                            DebugLocation(164, 39);
                                                            PushFollow(Follow._logicalExpression_in_function747);
                                                            logicalExpression47 = logicalExpression();
                                                            PopFollow();

                                                            stream_logicalExpression.Add(logicalExpression47.Tree);

                                                        }
                                                        break;

                                                    default:
                                                        goto loop11;
                                                }
                                            }

                                            loop11:
                                            ;

                                        }
                                        finally { DebugExitSubRule(11); }


                                    }
                                    break;

                            }
                        }
                        finally { DebugExitSubRule(12); }

                        DebugLocation(164, 62);
                        char_literal48 = (IToken)Match(input, 35, Follow._35_in_function754);
                        stream_35.Add(char_literal48);



                        {
                            // AST REWRITE
                            // elements: IDENT, logicalExpression
                            // token labels: 
                            // rule labels: retval
                            // token list labels: 
                            // rule list labels: 
                            // wildcard labels: 
                            retval.Tree = root_0;
                            RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.Tree : null);

                            root_0 = (CommonTree)adaptor.Nil();
                            // 164:66: -> ^( IDENT ( logicalExpression )* )
                            {
                                DebugLocation(164, 69);
                                // C:\\projects\\Expressions\\antlr\\Expression.g:164:69: ^( IDENT ( logicalExpression )* )
                                {
                                    CommonTree root_1 = (CommonTree)adaptor.Nil();
                                    DebugLocation(164, 71);
                                    root_1 = (CommonTree)adaptor.BecomeRoot(stream_IDENT.NextNode(), root_1);

                                    DebugLocation(164, 77);
                                    // C:\\projects\\Expressions\\antlr\\Expression.g:164:77: ( logicalExpression )*
                                    while (stream_logicalExpression.HasNext)
                                    {
                                        DebugLocation(164, 77);
                                        adaptor.AddChild(root_1, stream_logicalExpression.NextTree());

                                    }
                                    stream_logicalExpression.Reset();

                                    adaptor.AddChild(root_0, root_1);
                                }

                            }

                            retval.Tree = root_0;
                        }

                    }

                    retval.Stop = (IToken)input.LT(-1);

                    retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                    adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

                }
                catch (RecognitionException re)
                {
                    ReportError(re);
                    Recover(input, re);
                    retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

                }
                finally
                {
                    TraceOut("function", 15);
                    LeaveRule("function", 15);
                    Leave_function();
                }
                DebugLocation(165, 1);
            }
            finally { DebugExitRule(GrammarFileName, "function"); }
            return retval;

        }
        // $ANTLR end "function"
        #endregion Rules


        #region Follow sets
        private static class Follow
        {
            public static readonly BitSet _logicalExpression_in_expression72 = new BitSet(new ulong[] { 0x0UL });
            public static readonly BitSet _EOF_in_expression74 = new BitSet(new ulong[] { 0x2UL });
            public static readonly BitSet _booleanAndExpression_in_logicalExpression88 = new BitSet(new ulong[] { 0x202UL });
            public static readonly BitSet _OR_in_logicalExpression91 = new BitSet(new ulong[] { 0x45F840100UL });
            public static readonly BitSet _booleanAndExpression_in_logicalExpression94 = new BitSet(new ulong[] { 0x202UL });
            public static readonly BitSet _equalityExpression_in_booleanAndExpression124 = new BitSet(new ulong[] { 0x402UL });
            public static readonly BitSet _AND_in_booleanAndExpression127 = new BitSet(new ulong[] { 0x45F840100UL });
            public static readonly BitSet _equalityExpression_in_booleanAndExpression130 = new BitSet(new ulong[] { 0x402UL });
            public static readonly BitSet _relationalExpression_in_equalityExpression158 = new BitSet(new ulong[] { 0x1802UL });
            public static readonly BitSet _set_in_equalityExpression161 = new BitSet(new ulong[] { 0x45F840100UL });
            public static readonly BitSet _relationalExpression_in_equalityExpression168 = new BitSet(new ulong[] { 0x1802UL });
            public static readonly BitSet _additiveExpression_in_relationalExpression208 = new BitSet(new ulong[] { 0x1E002UL });
            public static readonly BitSet _set_in_relationalExpression212 = new BitSet(new ulong[] { 0x45F840100UL });
            public static readonly BitSet _additiveExpression_in_relationalExpression223 = new BitSet(new ulong[] { 0x1E002UL });
            public static readonly BitSet _multiplicativeExpression_in_additiveExpression266 = new BitSet(new ulong[] { 0x60002UL });
            public static readonly BitSet _set_in_additiveExpression270 = new BitSet(new ulong[] { 0x45F840100UL });
            public static readonly BitSet _multiplicativeExpression_in_additiveExpression277 = new BitSet(new ulong[] { 0x60002UL });
            public static readonly BitSet _powerExpression_in_multiplicativeExpression307 = new BitSet(new ulong[] { 0x380002UL });
            public static readonly BitSet _set_in_multiplicativeExpression311 = new BitSet(new ulong[] { 0x45F840100UL });
            public static readonly BitSet _powerExpression_in_multiplicativeExpression320 = new BitSet(new ulong[] { 0x380002UL });
            public static readonly BitSet _unaryExpression_in_powerExpression358 = new BitSet(new ulong[] { 0x400002UL });
            public static readonly BitSet _POW_in_powerExpression362 = new BitSet(new ulong[] { 0x45F840100UL });
            public static readonly BitSet _unaryExpression_in_powerExpression365 = new BitSet(new ulong[] { 0x400002UL });
            public static readonly BitSet _primaryExpression_in_unaryExpression388 = new BitSet(new ulong[] { 0x2UL });
            public static readonly BitSet _NOT_in_unaryExpression397 = new BitSet(new ulong[] { 0x45F000100UL });
            public static readonly BitSet _primaryExpression_in_unaryExpression400 = new BitSet(new ulong[] { 0x2UL });
            public static readonly BitSet _MINUS_in_unaryExpression409 = new BitSet(new ulong[] { 0x45F000100UL });
            public static readonly BitSet _primaryExpression_in_unaryExpression411 = new BitSet(new ulong[] { 0x2UL });
            public static readonly BitSet _34_in_primaryExpression447 = new BitSet(new ulong[] { 0x45F840100UL });
            public static readonly BitSet _logicalExpression_in_primaryExpression450 = new BitSet(new ulong[] { 0x800000000UL });
            public static readonly BitSet _35_in_primaryExpression452 = new BitSet(new ulong[] { 0x2UL });
            public static readonly BitSet _value_in_primaryExpression458 = new BitSet(new ulong[] { 0x2UL });
            public static readonly BitSet _INTEGER_in_value472 = new BitSet(new ulong[] { 0x2UL });
            public static readonly BitSet _FLOAT_in_value477 = new BitSet(new ulong[] { 0x2UL });
            public static readonly BitSet _STRING_in_value482 = new BitSet(new ulong[] { 0x2UL });
            public static readonly BitSet _function_in_value487 = new BitSet(new ulong[] { 0x2UL });
            public static readonly BitSet _reference_in_value492 = new BitSet(new ulong[] { 0x2UL });
            public static readonly BitSet _rangereference_in_value497 = new BitSet(new ulong[] { 0x2UL });
            public static readonly BitSet _par_in_value502 = new BitSet(new ulong[] { 0x2UL });
            public static readonly BitSet _REF_in_reference514 = new BitSet(new ulong[] { 0x2UL });
            public static readonly BitSet _REFRANGE_in_rangereference536 = new BitSet(new ulong[] { 0x2UL });
            public static readonly BitSet _PAR_in_par556 = new BitSet(new ulong[] { 0x2UL });
            public static readonly BitSet _IDENT_in_function736 = new BitSet(new ulong[] { 0x400000000UL });
            public static readonly BitSet _34_in_function738 = new BitSet(new ulong[] { 0xC5F840100UL });
            public static readonly BitSet _logicalExpression_in_function742 = new BitSet(new ulong[] { 0x1800000000UL });
            public static readonly BitSet _36_in_function745 = new BitSet(new ulong[] { 0x45F840100UL });
            public static readonly BitSet _logicalExpression_in_function747 = new BitSet(new ulong[] { 0x1800000000UL });
            public static readonly BitSet _35_in_function754 = new BitSet(new ulong[] { 0x2UL });

        }
        #endregion Follow sets
    }
}
